-
Notifications
You must be signed in to change notification settings - Fork 169
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Rest Client] Support for Cookies + Fix secret headers + Collectible errors #2474
base: main
Are you sure you want to change the base?
[Rest Client] Support for Cookies + Fix secret headers + Collectible errors #2474
Conversation
Upgraded the runtime to version 14.0 and extended ID range to accommodate newly introduced components. Added a comprehensive error handling system using enums for different error scenarios and a dedicated builder for error creation. Improved HttpClient functionality by allowing the creation and management of cookies within requests and responses, enhancing flexibility. Refactored HTTP methods with improved response checking, ensuring errors are collected and processed correctly. Fix handling of secret content headers. Refactored code with new constructor functions.
Replaced multiple overloads of HTTP request methods with simplified versions, removing boolean success indicators. Enhanced error handling by adopting collectible errors, and streamlined method implementations. Emphasized cleaner error descriptions in unsuccessful responses to improve debugging and user experience. Adjustments potentially improve maintainability and error traceability.
…oved clarity and consistency
…eadability and maintainability - Add missing newline at the end of HttpContent.Codeunit.al - Rename GetRestClientException method to GetExceptionCode in HttpResponseMessage.Codeunit.al - Remove unused GetExceptionName method in HttpResponseMessage.Codeunit.al - Remove unused GetExceptionCode and GetExceptionName methods in HttpResponseMessageImpl.Codeunit.al - Remove unused ConnectionErr and RequestFailedErr labels in RestClientImpl.Codeunit.al - Update RestClientImpl.Codeunit.al to handle error collection more efficiently - Add new codeunit HttpExceptionTests.Codeunit.al to test different types of exceptions - Add new test to RequestMessageTests.Codeunit.al to test adding secret headers
...tem Application/App/Rest Client/src/ExceptionHandling/RestClientExceptionBuilder.Codeunit.al
Show resolved
Hide resolved
src/System Application/Test/Rest Client/src/RequestMessageTests.Codeunit.al
Show resolved
Hide resolved
@ajkauffmann do I understand the changes with HttpContent := HttpContent.Create('Dummy'); can now be simplified to HttpContent.Create('Dummy'); |
It's actually the other way around. Since Create() returns the instance by means of |
Looks like this one already is ready for a review by the product group! Let me find a Rest Client expert, as I'm definitely not one of those 😝 |
src/System Application/App/Rest Client/src/HttpContentImpl.Codeunit.al
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice one. Looks fine to me!
src/System Application/Test/Rest Client/src/HttpExceptionTests.Codeunit.al
Outdated
Show resolved
Hide resolved
src/System Application/App/Rest Client/src/HttpContentImpl.Codeunit.al
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests calling external service (httpbin) have been causing us issues, when the service is down for any reason, our tests fail and block all the gates. We are working on HTTP mocking in the compiler scenarios, maybe we should wait until that's in place and refactor these tests?
"Request changes" is for Postman calls
…ming and remove the usage of this for clarity and readability.
And this is why we don't run tests with external dependencies in our CI: Error: Function TestWithUseResponseCookies Assert.AreEqual failed. Expected:<200> (Integer). Actual:<503> (Integer). The response status code should be 200. Let's disable those, and push forward 🥳 |
Summary
Adding support for cookies to the Rest Client
Fixing an issue with secret headers
Adding collectible error behavior
Redesigning internal code for better maintainability and uptaking new AL features like the keyword
this
Work Item(s)
Fixes #1479 #989
Fixes AB#560010